package com.charger.charger.controller;

import com.charger.charger.service.IChargerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName GetDataController
 * @Description TODO
 * @Author LiuYao
 * @Date 2024年11月28日 21:51
 * @Version 1.0
 */
@RestController
@RequestMapping("/getData")
public class GetDataController {
    @Autowired
    private IChargerService chargerService;
    @GetMapping
    public Map getData(){
        List<Integer> list= chargerService.getStatus();
        int chargingCount = 0,kongxianCount = 0,lixianCount = 0,guzhangCount = 0;
        for (int i=0; i < list.size();i++){
            if (i == 0){
                chargingCount++;
            }else if (i == 1){
                kongxianCount++;
            }else if (i == 2){
                lixianCount++;
            }else {
                guzhangCount++;
            }
        }
        Map map=new HashMap();
        map.put("chargingCount",chargingCount);
        map.put("kongxianCount",kongxianCount);
        map.put("lixianCount",lixianCount);
        map.put("guzhangCount",guzhangCount);
        return map;
    }
}
